package com.suning.sawp.service.impl.bi;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.annotation.Resource;
import javax.sql.DataSource;

import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
import org.joda.time.MutableDateTime;
import org.joda.time.format.DateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.suning.framework.dal.client.DalClient;
import com.suning.istore.common.bi.ftp.AbstractPropertySetter;
import com.suning.istore.common.bi.ftp.DefaultLineMapper;
import com.suning.istore.common.bi.ftp.FTPSynService;
import com.suning.istore.common.bi.ftp.ShardedLineMapper;
import com.suning.istore.common.bi.ftp.TodaySupplier;
import com.suning.istore.common.integration.BIDataCleanService;
import com.suning.istore.common.integration.ListeningAction;
import com.suning.istore.common.integration.SQLIterator;
import com.suning.istore.lang.BufferedAction.Action;
import com.suning.sawp.constants.TMConstants;
import com.suning.sawp.dto.customer.PtyMemberRecordDto;
import com.suning.sawp.dto.maindiscode.MainDiscodeDto;
import com.suning.sawp.intf.StaffInfoAware;
import com.suning.sawp.intf.dao.tm.TimeMachineDao;
import com.suning.sawp.intf.maindiscode.MainDiscodeService;
import com.suning.sawp.intf.store.StoreInfoService;
import com.suning.sawp.po.bi.BIIndexTaskCardEntity;
import com.suning.sawp.po.bi.BIModelAnalyseEntity;
import com.suning.sawp.po.bi.BIModelRecommendEntity;
import com.suning.sawp.po.bi.BIModelSaleTopEntity;
import com.suning.sawp.po.bi.BIPreChargeStatis;
import com.suning.sawp.po.bi.BISaleAnalyseEntity;
import com.suning.sawp.po.bi.BISaleNoPickOrderEntity;
import com.suning.sawp.po.bi.BIStaffCateYbDay;
import com.suning.sawp.po.bi.BIStaffCateYbMonth;
import com.suning.sawp.po.bi.BIStaffPushCommDay;
import com.suning.sawp.po.bi.BIStaffPushCommMonth;
import com.suning.sawp.po.bi.BIStaffPushTaskMonth;
import com.suning.sawp.po.bi.BIStaffSaleAllDay;
import com.suning.sawp.po.bi.BIStaffSaleAllMonth;
import com.suning.sawp.po.bi.BIStorePushCommMonth;
import com.suning.sawp.po.bi.BIStorePushTaskMonth;
import com.suning.sawp.po.bi.BIStoreSaleAllDay;
import com.suning.sawp.po.bi.BIStoreSaleAllMonth;
import com.suning.sawp.po.bi.BIStoreSaleCateDay;
import com.suning.sawp.po.bi.BIStoreSaleCateMonth;
import com.suning.sawp.po.bi.BiEmployeeCategoryInfoEntity;
import com.suning.sawp.po.bi.BiEmployeeExpensiveSaleInfoEntity;
import com.suning.sawp.po.bi.BiEmployeeFirstSaleInfoEntity;
import com.suning.sawp.po.bi.BiEmployeeHireInfoEntity;
import com.suning.sawp.po.bi.BiEmployeeMemberInfoEntity;
import com.suning.sawp.po.bi.BiEmployeeTotalSaleInfoEntity;
import com.suning.sawp.po.bi.BiModelAnalyseInEntity;
import com.suning.sawp.po.bi.BiModelSaleTopInEntity;
import com.suning.sawp.po.bi.BiStaffArriveSaleDayEntity;
import com.suning.sawp.po.bi.BiStaffArriveSaleMonthEntity;
import com.suning.sawp.po.bi.BiStaffArriveSaleWeekEntity;
import com.suning.sawp.po.bi.BiStaffDevelopDayEntity;
import com.suning.sawp.po.bi.BiStaffDevelopMonthEntity;
import com.suning.sawp.po.bi.BiStaffDevelopWeekEntity;
import com.suning.sawp.po.bi.BiStaffDevelopingActivitySaleMonthEntity;
import com.suning.sawp.po.bi.BiStaffDevelopingSaleMonthEntity;
import com.suning.sawp.po.bi.BiStaffRecommendSaleDayEntity;
import com.suning.sawp.po.bi.BiStaffRecommendSaleMonthEntity;
import com.suning.sawp.po.bi.BiStaffRecommendSaleWeekEntity;
import com.suning.sawp.po.bi.BiStoreArriveSaleMonthEntity;
import com.suning.sawp.po.bi.BiStoreBranchRetGdsDayBean;
import com.suning.sawp.po.bi.BiStoreBranchRetGdsMonthBean;
import com.suning.sawp.po.bi.BiStoreBranchRetGdsWeekBean;
import com.suning.sawp.po.bi.BiStoreCateBrandDay;
import com.suning.sawp.po.bi.BiStoreCateBrandMonth;
import com.suning.sawp.po.bi.BiStoreCateBrandMonthTop1;
import com.suning.sawp.po.bi.BiStoreCateMonSaleTask;
import com.suning.sawp.po.bi.BiStoreCateRetGdsDayBean;
import com.suning.sawp.po.bi.BiStoreCateRetGdsMonthBean;
import com.suning.sawp.po.bi.BiStoreCateRetGdsWeekBean;
import com.suning.sawp.po.bi.BiStoreDevelopDayEntity;
import com.suning.sawp.po.bi.BiStoreDevelopMonthEntity;
import com.suning.sawp.po.bi.BiStoreDevelopWeekEntity;
import com.suning.sawp.po.bi.BiStoreDevelopingActivitySaleMonthEntity;
import com.suning.sawp.po.bi.BiStoreDevelopingSaleMonthEntity;
import com.suning.sawp.po.bi.BiStoreLastYearSale;
import com.suning.sawp.po.bi.BiStoreMonSaleTask;
import com.suning.sawp.po.bi.BiStoreOosDetailEntity;
import com.suning.sawp.po.bi.BiStoreOosEntity;
import com.suning.sawp.po.bi.BiStoreRealIncDetailMEntity;
import com.suning.sawp.po.bi.BiStoreRecommendSaleMonthEntity;
import com.suning.sawp.po.bi.BiStoreRetGdsDayBean;
import com.suning.sawp.po.bi.BiStoreRetGdsMonthBean;
import com.suning.sawp.po.bi.StoreRegMemberDetailDEntity;
import com.suning.sawp.po.store.StoreInfo;
import com.suning.sawp.service.impl.bi.support.BIAsyncListener;
import com.suning.sawp.service.impl.bi.support.MultiContextWithDefinition;
import com.suning.sawp.service.impl.bi.support.SimpleContextWithDefinition;
import com.suning.sawp.service.impl.job.DBBIDeleteJob;
import com.suning.sawp.service.impl.tm.TmBatchUpdateAction;
import com.suning.sawp.service.util.DateUtils;
import com.suning.sawp.service.util.RedisCacheUtils;

/**
 * 大数据报表入库
 * 
 * @author 13071602
 *
 */
public class BIReportServiceImpl implements BIReportService {

    /**
     * 日志
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(BIReportServiceImpl.class);

    /**
     * 主要考虑调以后分库分表的支持
     */
    @Autowired
    DalClient dalClient;
    @Autowired
    BatchUpdateService batchUpdateService;
    @Autowired
    TimeMachineDao timeMachineDao;
    @Resource
    private RedisCacheUtils cacheUtils;
    @Autowired
    FTPSynService ftpSynService;

    /**
     * 抽取数据的数据源
     */
    @Autowired
    @Qualifier("sawpjndi")
    DataSource dataSource;

    @Autowired
    DBBIDeleteJob dbBIDeleteJob;

    @Autowired
    BIAsyncListener asyncListener;

    /**
     * 大区映射关系服务
     */
    @Autowired
    MainDiscodeService mainDiscodeService;

    /**
     * 门店服务
     */
    @Autowired
    StoreInfoService storeInfoService;

    private Map<String, String> selectSqls;

    public Map<String, String> getSelectSqls() {
        return selectSqls;
    }

    public void setSelectSqls(Map<String, String> selectSqls) {
        this.selectSqls = selectSqls;
    }

    /*
     * (non-Javadoc)
     * @see com.suning.sawp.service.impl.bi.BIReportService#uploadPreChargeAct(java.lang.String, java.lang.String)
     */
    @Override
    public void uploadPreChargeAct(String remoteDirectory, final String date, String fileName) throws SQLException {
        final String lineSeparator = "|@|\n";
        // 默认上传到今天的文件目录
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator,
                new SQLIterator(dataSource, selectSqls.get("uploadPreChargeAct")) {
                    protected void setValues(PreparedStatement ps) throws SQLException {
                        ps.setDate(1, new java.sql.Date(localDate.minusDays(1).toDate().getTime()));
                    }
                }, new Function<Map<String, Object>, String>() {
                    @Override
                    public String apply(Map<String, Object> row) {
                        return Joiner.on("|$|").join(
                                Iterables.transform(row.entrySet(), new Function<Map.Entry<String, Object>, String>() {
                            @Override
                            public String apply(Entry<String, Object> input) {
                                // 默认直接处理成字符串
                                Object val = input.getValue();
                                if (null == val) {
                                    return "<NULL>";
                                }
                                if ("startTime".equals(input.getKey())) {
                                    // 时间有效位置到日期
                                    MutableDateTime time = MutableDateTime.parse(String.valueOf(val),
                                            DateTimeFormat.forPattern("yyyyMMdd"));
                                    return time.toString("yyyyMMdd");
                                } else if ("endTime".equals(input.getKey())) {
                                    // 时间有效位置到日期
                                    MutableDateTime time = MutableDateTime.parse(String.valueOf(val),
                                            DateTimeFormat.forPattern("yyyyMMdd"));
                                    return time.toString("yyyyMMdd");
                                }
                                return val.toString();
                            }
                        }));

                    }

                }, -1);

    }

    /*
     * (non-Javadoc)
     * @see com.suning.sawp.service.impl.bi.BIReportService#uploadMainPush(java.lang.String, java.lang.String)
     */
    @Override
    public void uploadMainPush(String remoteDirectory, final String date, String fileName) throws SQLException {
        final String lineSeparator = "|@|\n";
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator,
                new SQLIterator(dataSource, selectSqls.get("uploadMainPush")) {
                    protected void setValues(PreparedStatement ps) throws SQLException {
                        // 取当月数据
                        ps.setString(1, DateUtils.getMonth(localDate.minusDays(1).toDate().getTime()));
                    }
                }, new Function<Map<String, Object>, String>() {
                    @Override
                    public String apply(Map<String, Object> row) {
                        return Joiner.on("|$|").join(
                                Iterables.transform(row.entrySet(), new Function<Map.Entry<String, Object>, String>() {
                            @Override
                            public String apply(Entry<String, Object> input) {
                                // 默认直接处理成字符串
                                Object val = input.getValue();
                                if (null == val) {
                                    return "<NULL>";
                                }
                                return val.toString();
                            }
                        }));

                    }

                }, -1);

    }

    /*
     * (non-Javadoc)
     * @see com.suning.sawp.service.impl.bi.BIReportService#uploadMainPush(java.lang.String, java.lang.String)
     */
    @Override
    public void uploadMainPushComm(String remoteDirectory, final String date, String fileName) throws SQLException {
        final String lineSeparator = "|@|\n";
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator,
                new SQLIterator(dataSource, selectSqls.get("uploadMainPushComm")) {
                    protected void setValues(PreparedStatement ps) throws SQLException {
                        // 取当月数据
                        ps.setString(1, DateUtils.getMonth(localDate.minusDays(1).toDate().getTime()));
                    }
                }, new Function<Map<String, Object>, String>() {
                    @Override
                    public String apply(Map<String, Object> row) {
                        return Joiner.on("|$|").join(
                                Iterables.transform(row.entrySet(), new Function<Map.Entry<String, Object>, String>() {
                            @Override
                            public String apply(Entry<String, Object> input) {
                                // 默认直接处理成字符串
                                Object val = input.getValue();
                                if (null == val) {
                                    return "<NULL>";
                                }
                                if ("startTime".equals(input.getKey())) {
                                    // 时间有效位置到日期
                                    return DateUtils.getLongStr(DateUtils.getFirstDateOfMonth(localDate.toDate()));
                                } else if ("endTime".equals(input.getKey())) {
                                    // 时间有效位置到日期
                                    return DateUtils.getLongStr(DateUtils.getLastDateOfMonth(localDate.toDate()));
                                }
                                return val.toString();
                            }
                        }));
                    }
                }, -1);

    }

    @Override
    public void uploadCustomerRelation4Out(String remoteDirectory, final String date, String fileName)
            throws SQLException {
        final String lineSeparator = "|@|\n";
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator,
                new SQLIterator(dataSource, selectSqls.get("customerRelation4Out")) {
                    protected void setValues(PreparedStatement ps) throws SQLException {
                        ps.setDate(1, new java.sql.Date(localDate.minusDays(1).toDate().getTime()));
                        ps.setDate(2, new java.sql.Date(localDate.minusDays(1).toDate().getTime()));
                    }
                }, new Function<Map<String, Object>, String>() {
                    @Override
                    public String apply(Map<String, Object> row) {
                        return Joiner.on("|$|").join(
                                Iterables.transform(row.entrySet(), new Function<Map.Entry<String, Object>, String>() {
                            @Override
                            public String apply(Entry<String, Object> input) {
                                // 默认直接处理成字符串
                                Object val = input.getValue();
                                if (null == val) {
                                    return "";
                                }
                                return val.toString();
                            }
                        }));

                    }

                }, -1);
    }

    @Override
    public void uploadCustomerRelation4Arrive(String remoteDirectory, final String date, String fileName)
            throws SQLException {
        final String lineSeparator = "|@|\n";
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator,
                new SQLIterator(dataSource, selectSqls.get("customerRelation4Arrive")) {
                    protected void setValues(PreparedStatement ps) throws SQLException {
                        ps.setDate(1, new java.sql.Date(localDate.minusDays(1).toDate().getTime()));
                        ps.setDate(2, new java.sql.Date(localDate.toDate().getTime()));
                    }
                }, new Function<Map<String, Object>, String>() {
                    @Override
                    public String apply(Map<String, Object> row) {
                        return Joiner.on("|$|").join(
                                Iterables.transform(row.entrySet(), new Function<Map.Entry<String, Object>, String>() {
                            @Override
                            public String apply(Entry<String, Object> input) {
                                // 默认直接处理成字符串
                                Object val = input.getValue();
                                if (null == val) {
                                    return "";
                                }
                                return val.toString();
                            }
                        }));

                    }

                }, -1);
    }

    @Override
    public void uploadStaffFlowingCustomer(String remoteDirectory, final String date, String fileName)
            throws SQLException {
        final String lineSeparator = "|@|\n";
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator,
                new SQLIterator(dataSource, selectSqls.get("staffFlowingCustomer")) {
                    protected void setValues(PreparedStatement ps) throws SQLException {
                        ps.setDate(1, new java.sql.Date(localDate.minusDays(1).toDate().getTime()));
                    }
                }, new Function<Map<String, Object>, String>() {
                    @Override
                    public String apply(Map<String, Object> row) {
                        return Joiner.on("|$|").join(
                                Iterables.transform(row.entrySet(), new Function<Map.Entry<String, Object>, String>() {
                            @Override
                            public String apply(Entry<String, Object> input) {
                                // 默认直接处理成字符串
                                Object val = input.getValue();
                                if (null == val) {
                                    return "";
                                }
                                return val.toString();
                            }
                        }));

                    }

                }, -1);
    }

    /**
     * 01
     */
    @Override
    public void downloadBIStaffSaleAllMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIStaffSaleAllMonth.class, "|@|\n",
                        new DefaultLineMapper<BIStaffSaleAllMonth>(BIStaffSaleAllMonth.class,
                                new String[] { "ranking", "saleVolume", "saleAmount", "staffId", "staffName",
                                        "storeCode", "storeName", "disCode", "disName", "saleMonth", "updateTime" },
                                "|$|", new SalePropertySetter<BIStaffSaleAllMonth>()),
                        new BIStaffDataCleanService<BIStaffSaleAllMonth>(),
                        new BatchUpdateAction<BIStaffSaleAllMonth>("BI_STAFF_SALE_ALL_MONTH.REPLACE")),
                false);
    }

    /**
     * 02
     */
    @Override
    public void downloadBIStaffSaleAllDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIStaffSaleAllDay.class, "|@|\n",
                        new DefaultLineMapper<BIStaffSaleAllDay>(BIStaffSaleAllDay.class,
                                new String[] { "ranking", "saleVolume", "saleAmount", "staffId", "staffName",
                                        "storeCode", "storeName", "disCode", "disName", "saleDate", "updateTime" },
                                "|$|", new SalePropertySetter<BIStaffSaleAllDay>()),
                        new BIStaffDataCleanService<BIStaffSaleAllDay>(),
                        new BatchUpdateAction<BIStaffSaleAllDay>("BI_STAFF_SALE_ALL_DAY.REPLACE")),
                false);
    }

    /**
     * 03 【BI_STORE_SALE_CATE_MONTH】
     */
    @Override
    public void downloadBIStoreSaleCateMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStoreSaleCateMonth.class, "|@|\n",
                new DefaultLineMapper<BIStoreSaleCateMonth>(BIStoreSaleCateMonth.class,
                        new String[] { "ranking", "saleVolume", "saleAmount", "cateCode", "storeCode", "storeName",
                                "disCode", "disName", "saleMonth", "updateTime", "lastMonthSaleAmount", "custAvgPrice",
                                "lastMonthCustAvgPrice", "lastYearSaleAmount", "lastYearCustAvgPrice", "branchCode", "branchName",
                                "lastYearVolume"  ,"positiveSaleVolume","positiveSaleAmount","negativeSaleVolume" ,"negativeSaleAmount","custNum","lastYearCustNum","jxcAmount","lastYearJxcAmount" },
                        "|$|", new SalePropertySetterEx<BIStoreSaleCateMonth>()),
                null, new BatchUpdateAction<BIStoreSaleCateMonth>("BI_STORE_SALE_CATE_MONTH.REPLACE")), false);
    }

    /**
     * 04 BI_STORE_SALE_CATE_DAY
     */
    @Override
    public void downloadBIStoreSaleCateDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIStoreSaleCateDay.class, "|@|\n",
                        new DefaultLineMapper<BIStoreSaleCateDay>(BIStoreSaleCateDay.class,
                                new String[] { "ranking", "saleVolume", "saleAmount", "cateCode", "storeCode",
                                        "storeName", "disCode", "disName", "saleDate", "updateTime", "custAvgPrice"
                                        ,"lastYearSaleAmount","lastYearVolume","positiveSaleVolume","positiveSaleAmount","negativeSaleVolume" ,"negativeSaleAmount","custNum","jxcAmount","lastYearJxcAmount","lastYearCustNum" },
                                "|$|", new SalePropertySetterEx<BIStoreSaleCateDay>()),
                        null, new BatchUpdateAction<BIStoreSaleCateDay>("BI_STORE_SALE_CATE_DAY.REPLACE")),
                false);
    }

    /**
     * 05 【BI_STORE_SALE_ALL_MONTH】
     */
    @Override
    public void downloadBIStoreSaleAllMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIStoreSaleAllMonth.class, "|@|\n",
                        new DefaultLineMapper<BIStoreSaleAllMonth>(BIStoreSaleAllMonth.class,
                                new String[] { "ranking", "saleVolume", "saleAmount", "storeCode", "storeName",
                                        "disCode", "disName", "saleMonth", "updateTime", "lastMonthSaleAmount",
                                        "custAvgPrice", "lastMonthCustAvgPrice", "saleCompleteRate", "lastYearSaleAmount", "lastYearCustAvgPrice",
                                        "lastYearVolume"  ,"positiveSaleVolume","positiveSaleAmount","negativeSaleVolume" ,"negativeSaleAmount","custNum","lastYearCustNum","jxcAmount","lastYearJxcAmount"  },
                                "|$|", new SalePropertySetterEx<BIStoreSaleAllMonth>()),
                        null, new BatchUpdateAction<BIStoreSaleAllMonth>("BI_STORE_SALE_ALL_MONTH.REPLACE")),
                false);
    }

    /**
     * 06
     */
    @Override
    public void downloadBIStoreSaleAllDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIStoreSaleAllDay.class, "|@|\n",
                        new DefaultLineMapper<BIStoreSaleAllDay>(BIStoreSaleAllDay.class,
                                new String[] { "ranking", "saleVolume", "saleAmount", "storeCode", "storeName",
                                        "disCode", "disName", "saleDate", "updateTime" ,
                                        "custAvgPrice","lastYearSaleAmount","lastYearVolume"   ,"positiveSaleVolume","positiveSaleAmount","negativeSaleVolume" ,"negativeSaleAmount","custNum","jxcAmount","lastYearJxcAmount","lastYearCustNum"  },
                                "|$|", new SalePropertySetterEx<BIStoreSaleAllDay>()),
                        null, new BatchUpdateAction<BIStoreSaleAllDay>("BI_STORE_SALE_ALL_DAY.REPLACE")),
                false);

    }

    /**
     * 07
     */
    @Override
    public void downloadBIStaffPushTaskMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStaffPushTaskMonth.class, "|@|\n",
                new DefaultLineMapper<BIStaffPushTaskMonth>(BIStaffPushTaskMonth.class,
                        new String[] { "ranking", "rankDiff", "saleVolume", "saleAmount", "storeCode", "storeName",
                                "disCode", "disName", "cateCode", null, "staffId", "staffName", "saleMonth",
                                "updateTime" },
                        "|$|", new SalePropertySetter<BIStaffPushTaskMonth>()),
                new BIStaffDataCleanService<BIStaffPushTaskMonth>(),
                new BatchUpdateAction<BIStaffPushTaskMonth>("BI_STAFF_PUSH_TASK_MONTH.REPLACE")), false);
    }

    /**
     * 08
     */
    @Override
    public void downloadBIStorePushTaskMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStorePushTaskMonth.class, "|@|\n",
                new DefaultLineMapper<BIStorePushTaskMonth>(BIStorePushTaskMonth.class,
                        new String[] { "ranking", "rankDiff", "saleVolume", "saleAmount", "storeCode", "cateCode",
                                "hqTaskId", "storeName", "disCode", "disName", "saleMonth", "updateTime", "pushType"},
                        "|$|", new SalePropertySetter<BIStorePushTaskMonth>()),
                null, new BatchUpdateAction<BIStorePushTaskMonth>("BI_STORE_PUSH_TASK_MONTH.REPLACE")), false);
    }

    /**
     * 09
     */
    @Override
    public void downloadBIStorePushCommMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStorePushCommMonth.class, "|@|\n",
                new DefaultLineMapper<BIStorePushCommMonth>(BIStorePushCommMonth.class,
                        new String[] { "saleVolume", "saleAmount", "modelId", null, "storeCode", "cateCode",
                                "hqTaskId", "storeName", "disCode", "disName", "saleMonth", "updateTime" },
                        "|$|", new SalePropertySetter<BIStorePushCommMonth>()),
                null, new BatchUpdateAction<BIStorePushCommMonth>("BI_STORE_PUSH_COMM_MONTH.REPLACE")), false);
    }

    /**
     * 10
     */
    @Override
    public void downloadBIStaffPushCommMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStaffPushCommMonth.class, "|@|\n",
                new DefaultLineMapper<BIStaffPushCommMonth>(BIStaffPushCommMonth.class,
                        new String[] { "saleVolume", "saleAmount", "staffId", "staffName", "modelId", "storeCode",
                                "cateCode", null, "storeName", "disCode", "disName", "saleMonth", "updateTime" },
                        "|$|", new SalePropertySetter<BIStaffPushCommMonth>()),
                new BIStaffDataCleanService<BIStaffPushCommMonth>(),
                new BatchUpdateAction<BIStaffPushCommMonth>("BI_STAFF_PUSH_COMM_MONTH.REPLACE")), false);
    }

    /**
     * 11
     */
    @Override
    public void downloadBIStaffPushCommDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStaffPushCommDay.class, "|@|\n",
                new DefaultLineMapper<BIStaffPushCommDay>(BIStaffPushCommDay.class,
                        new String[] { "saleVolume", "saleAmount", "staffId", "staffName", "modelId", "storeCode",
                                "cateCode", null, "storeName", "disCode", "disName", "saleDate", "updateTime" },
                        "|$|", new SalePropertySetter<BIStaffPushCommDay>()),
                new BIStaffDataCleanService<BIStaffPushCommDay>(),
                new BatchUpdateAction<BIStaffPushCommDay>("BI_STAFF_PUSH_COMM_DAY.REPLACE")), false);
    }

    /**
     * 12
     */
    @Override
    public void downloadBIPreChargeStatis(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIPreChargeStatis.class, "|@|\n",
                        new DefaultLineMapper<BIPreChargeStatis>(BIPreChargeStatis.class,
                                new String[] { "chargeCount", null, "couponAmount", "staffId", "staffName", "storeCode",
                                        "statisTime", "updateTime" },
                                "|$|", new AbstractPropertySetter<BIPreChargeStatis>() {
                                    @Override
                                    protected Optional<Object> property(String name, String value) throws Exception {
                                        if ("updateTime".equals(name)) {
                                            return Optional.of(
                                                    (Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                        } else {
                                            return Optional.absent();
                                        }
                                    }
                                }),
                        new BIStaffDataCleanService<BIPreChargeStatis>(),
                        new BatchUpdateAction<BIPreChargeStatis>("BI_PRECHARGE_STATIS.REPLACE")),
                false);
    }

    /**
     * 【13】【BI_STORE_RET_GDS_DAY】<br/>
     */
    @Override
    public void downloadBIStoreRetGdsDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        // sqlMap_BiStoreRetGdsDay.xml
        ftpSynService
                .downloadBIFile(remoteDirectory, fileName, localDate,
                        new SimpleContextWithDefinition(BiStoreRetGdsDayBean.class, "|@|\n",
                                new DefaultLineMapper<BiStoreRetGdsDayBean>(BiStoreRetGdsDayBean.class,
                                        new String[] { "storeCode", "saleVolume", "saleAmount", "statisDate", "week",
                                                "year" },
                                        "|$|", new RefundSalePropertySetter<BiStoreRetGdsDayBean>()),
                                new BIDataCleanService<BiStoreRetGdsDayBean>() {
                                    @Override
                                    public boolean clean(BiStoreRetGdsDayBean obj) {
                                        obj.setDate(obj.getStatisDate());
                                        return true;
                                    }
                                }, new BatchUpdateAction<BiStoreRetGdsDayBean>("BI_STORE_RET_GDS_DAY.REPLACE")),
                        false);
    }

    /**
     * 14 【BI_STORE_BRANCH_RET_GDS_DAY】
     * 
     */
    @Override
    public void downloadBIStoreBranchRetGdsDay(String remoteDirectory, String date, String fileName)
            throws IOException {
        // sqlMap_BiStoreBranchRetGdsDay.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreBranchRetGdsDayBean.class, "|@|\n",
                new DefaultLineMapper<BiStoreBranchRetGdsDayBean>(BiStoreBranchRetGdsDayBean.class,
                        new String[] { "retGdsRate", "retGdsNum", "refund", "yestdRetGdsNum", "yestdRefund",
                                "lastYearRetGdsNum", "lastYearRefund", "saleVolume", "saleAmount", "yestdSaleVolume",
                                "yestdSaleAmount", "lastYearSaleVolume", "lastYearSaleAmount", "branch9code",
                                "branchName", "cateCode", "cateName", "branch4code", "storeCode", "storeName",
                                "disCode", "disName", "statisDate", "weekday", "week", "month", "year" },
                        "|$|", new RefundSalePropertySetter<BiStoreBranchRetGdsDayBean>()),
                new BIDataCleanService<BiStoreBranchRetGdsDayBean>() {
                    @Override
                    public boolean clean(BiStoreBranchRetGdsDayBean obj) {
                        obj.setDate(obj.getStatisDate());
                        return true;
                    }
                }, new BatchUpdateAction<BiStoreBranchRetGdsDayBean>("BI_STORE_BRANCH_RET_GDS_DAY.REPLACE")), false);
    }

    /**
     * 15 【BI_STORE_CATE_RET_GDS_DAY】 <br/>
     */
    @Override
    public void downloadBIStoreCateRetGdsDay(String remoteDirectory, String date, String fileName) throws IOException {
        // sqlMap_BiStoreCateRetGdsDay.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreCateRetGdsDayBean.class, "|@|\n",
                new DefaultLineMapper<BiStoreCateRetGdsDayBean>(BiStoreCateRetGdsDayBean.class,
                        new String[] { "retGdsRate", "retGdsNum", "refund", "yestdRetGdsNum", "yestdRefund",
                                "lastYearRetGdsNum", "lastYearRefund", "saleVolume", "saleAmount", "yestdSaleVolume",
                                "yestdSaleAmount", "lastYeaSaleVolume", "lastYearSaleAmount", "cateCode", "cateName",
                                "storeCode", "storeName", "disCode", "disName", "statisDate", "month", "year" },
                        "|$|", new RefundSalePropertySetter<BiStoreCateRetGdsDayBean>()),
                new BIDataCleanService<BiStoreCateRetGdsDayBean>() {
                    @Override
                    public boolean clean(BiStoreCateRetGdsDayBean obj) {
                        obj.setDate(obj.getStatisDate());
                        return true;
                    }
                }, new BatchUpdateAction<BiStoreCateRetGdsDayBean>("BI_STORE_CATE_RET_GDS_DAY.REPLACE")), false);
    }

    /**
     * 16 【BI_STORE_BRANCH_RET_GDS_WEEK】
     *
     */
    @Override
    public void downloadBIStoreBranchRetGdsWeek(String remoteDirectory, String date, String fileName)
            throws IOException {
        // sqlMap_BiStoreBranchRetGdsWeek.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreBranchRetGdsWeekBean.class, "|@|\n",
                new DefaultLineMapper<BiStoreBranchRetGdsWeekBean>(BiStoreBranchRetGdsWeekBean.class,
                        new String[] { "retGdsRate", "retGdsNum", "refund", "lastWeekRetGdsNum", "lastWeekRefund",
                                "lastYearRetGdsNum", "lastYearRefund", "saleVolume", "saleAmount", "lastWeekSaleVolume",
                                "lastWeekSaleAmount", "lastYearSaleVolume", "lastYearSaleAmount", "branch9code",
                                "branchName", "cateCode", "cateName", "branch4code", "storeCode", "storeName",
                                "disCode", "disName", "statisDate", "week", "year" },
                        "|$|", new RefundSalePropertySetter<BiStoreBranchRetGdsWeekBean>()),
                null, new BatchUpdateAction<BiStoreBranchRetGdsWeekBean>("BI_STORE_BRANCH_RET_GDS_WEEK.REPLACE")),
                false);
    }

    /**
     * 17 【BI_STORE_CATE_RET_GDS_WEEK】
     * 
     * 
     * 
     */
    @Override
    public void downloadBIStoreCateRetGdsWeek(String remoteDirectory, String date, String fileName) throws IOException {

        // sqlMap_BiStoreCateRetGdsWeek.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreCateRetGdsWeekBean.class, "|@|\n",
                new DefaultLineMapper<BiStoreCateRetGdsWeekBean>(BiStoreCateRetGdsWeekBean.class,
                        new String[] { "retGdsRate", "retGdsNum", "refund", "lastWeekRetGdsNum", "lastWeekRefund",
                                "lastYearRetGdsNum", "lastYearRefund", "saleVolume", "saleAmount", "lastWeekSaleVolume",
                                "lastWeekSaleAmount", "lastYearSaleVolume", "lastYearSaleAmount", "cateCode",
                                "cateName", "storeCode", "storeName", "disCode", "disName", "statisDate", "week",
                                "year" },
                        "|$|", new RefundSalePropertySetter<BiStoreCateRetGdsWeekBean>()),
                null, new BatchUpdateAction<BiStoreCateRetGdsWeekBean>("BI_STORE_CATE_RET_GDS_WEEK.REPLACE")), false);
    }

    /**
     * 18 【BI_STORE_BRANCH_RET_GDS_MONTH】
     */
    @Override
    public void downloadBIStoreBranchRetGdsMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        // sqlMap_BiStoreBranchRetGdsMonth.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreBranchRetGdsMonthBean.class, "|@|\n",
                new DefaultLineMapper<BiStoreBranchRetGdsMonthBean>(BiStoreBranchRetGdsMonthBean.class,
                        new String[] { "retGdsRate", "retGdsNum", "refund", "lastMonRetGdsNum", "lastMonRefund",
                                "lastYearRetGdsNum", "lastYearRefund", "saleVolume", "saleAmount", "lastMonSaleVolume",
                                "lastMonSaleAmount", "lastYearSaleVolume", "lastYearSaleAmount", "branch9code",
                                "branchName", "cateCode", "cateName", "branch4code", "storeCode", "storeName",
                                "disCode", "disName", "statisDate", "month", "year" },
                        "|$|", new RefundSalePropertySetter<BiStoreBranchRetGdsMonthBean>()),
                null, new BatchUpdateAction<BiStoreBranchRetGdsMonthBean>("BI_STORE_BRANCH_RET_GDS_MONTH.REPLACE")),
                false);
    }

    /**
     * 【19】 <br/>
     * 【BI_STORE_RET_GDS_MONTH】
     */
    @Override
    public void downloadBIStoreRetGdsMonth(String remoteDirectory, String date, String fileName) throws IOException {
        // sqlMap_BiStoreRetGdsMonth.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreRetGdsMonthBean.class, "|@|\n",
                new DefaultLineMapper<BiStoreRetGdsMonthBean>(BiStoreRetGdsMonthBean.class,
                        new String[] { "rank", "retGdsRate", "retGdsNum", "refund", "lastMonRetGdsNum", "lastMonRefund",
                                "lastYearRetGdsNum", "lastYearRefund", "saleVolume", "saleAmount", "lastMonSaleVolume",
                                "lastMonSaleAmount", "lastYearSaleVolume", "lastYearSaleAmount", "storeCode",
                                "storeName", "disCode", "disName", "statisDate", "month", "year" },
                        "|$|", new RefundSalePropertySetter<BiStoreRetGdsMonthBean>()),
                new BIDataCleanService<BiStoreRetGdsMonthBean>() {
                    @Override
                    public boolean clean(BiStoreRetGdsMonthBean obj) {
                        obj.setMonth(obj.getStatisDate().substring(0, 6));
                        return true;
                    }
                }, new BatchUpdateAction<BiStoreRetGdsMonthBean>("BI_STORE_RET_GDS_MONTH.REPLACE")), false);
    }

    /**
     * 20 <br/>
     * 【BI_STORE_CATE_RET_GDS_MONTH】
     */
    @Override
    public void downloadBIStoreCateRetGdsMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        // sqlMap_BiStoreCateRetGdsMonth.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreCateRetGdsMonthBean.class, "|@|\n",
                new DefaultLineMapper<BiStoreCateRetGdsMonthBean>(BiStoreCateRetGdsMonthBean.class,
                        new String[] { "rank", "retGdsRate", "retGdsNum", "refund", "lastMonRetGdsNum", "lastMonRefund",
                                "lastYearRetGdsNum", "lastYearRefund", "saleVolume", "saleAmount", "lastMonSaleVolume",
                                "lastMonSaleAmount", "lastYearSaleVolume", "lastYearSaleAmount", "cateCode", "cateName",
                                "storeCode", "storeName", "disCode", "disName", "statisDate", "month", "year", },
                        "|$|", new RefundSalePropertySetter<BiStoreCateRetGdsMonthBean>()),
                new BIDataCleanService<BiStoreCateRetGdsMonthBean>() {
                    @Override
                    public boolean clean(BiStoreCateRetGdsMonthBean obj) {
                        obj.setMonth(obj.getStatisDate().substring(0, 6));
                        return true;
                    }
                }, new BatchUpdateAction<BiStoreCateRetGdsMonthBean>("BI_STORE_CATE_RET_GDS_MONTH.REPLACE")), false);
    }

    /**
     * 2701 <br/>
     * BI_STAFF_RECOMMEND_SALE_MONTH
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStaffRecommendSaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffRecommendSaleMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffRecommendSaleMonthEntity>(BiStaffRecommendSaleMonthEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developNum",
                                        "developedNum", "developedOrder", "developedSale", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStaffRecommendSaleMonthEntity>()),
                        null,
                        new BatchUpdateAction<BiStaffRecommendSaleMonthEntity>("biStaffRecommendSaleMonth.replace")),
                false);
    }

    /**
     * 2702 <br>
     * bi_staff_arrive_sale_month
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStaffArriveSaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffArriveSaleMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffArriveSaleMonthEntity>(BiStaffArriveSaleMonthEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developNum",
                                        "developedNum", "developedOrder", "developedSale", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStaffArriveSaleMonthEntity>()),
                        null, new BatchUpdateAction<BiStaffArriveSaleMonthEntity>("biStaffArriveSaleMonth.replace")),
                false);
    }

    /**
     * 2703 <br/>
     * 【bi_store_recommend_sale_month】
     */
    @Override
    public void downloadBIStoreRecommendSaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreRecommendSaleMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStoreRecommendSaleMonthEntity>(BiStoreRecommendSaleMonthEntity.class,
                                new String[] { "storeCode", "storeName", "developNum", "developedNum", "developedOrder",
                                        "developedSale", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStoreRecommendSaleMonthEntity>()),
                        null,
                        new BatchUpdateAction<BiStoreRecommendSaleMonthEntity>("biStoreRecommendSaleMonth.replace")),
                false);
    }

    /**
     * 2704 <br/>
     * 【bi_store_arrive_sale_month】
     */
    @Override
    public void downloadBIStoreArriveSaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreArriveSaleMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStoreArriveSaleMonthEntity>(BiStoreArriveSaleMonthEntity.class,
                                new String[] { "storeCode", "storeName", "developNum", "developedNum", "developedOrder",
                                        "developedSale", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStoreArriveSaleMonthEntity>()),
                        null, new BatchUpdateAction<BiStoreArriveSaleMonthEntity>("biStoreArriveSaleMonth.replace")),
                false);
    }

    /**
     * 2705 <br/>
     * BI_STAFF_RECOMMEND_SALE_WEEK
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStaffRecommendSaleWeek(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffRecommendSaleWeekEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffRecommendSaleWeekEntity>(BiStaffRecommendSaleWeekEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developNum",
                                        "developedNum", "developedOrder", "developedSale", "statsWeekOfYear" },
                                "|$|", new DevelopPropertySetter<BiStaffRecommendSaleWeekEntity>()),
                        null,
                        new BatchUpdateAction<BiStaffRecommendSaleWeekEntity>("biStaffRecommendSaleWeek.replace")),
                false);
    }

    /**
     * 2706 <br/>
     * [bi_staff_arrive_sale_week]
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStaffArriveSaleWeek(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffArriveSaleWeekEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffArriveSaleWeekEntity>(BiStaffArriveSaleWeekEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developNum",
                                        "developedNum", "developedOrder", "developedSale", "statsWeekOfYear" },
                                "|$|", new DevelopPropertySetter<BiStaffArriveSaleWeekEntity>()),
                        null, new BatchUpdateAction<BiStaffArriveSaleWeekEntity>("biStaffArriveSaleWeek.replace")),
                false);
    }

    /**
     * 2707 <br/>
     * BI_STAFF_RECOMMEND_SALE_DAY
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStaffRecommendSaleDay(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffRecommendSaleDayEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffRecommendSaleDayEntity>(BiStaffRecommendSaleDayEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developNum",
                                        "developedNum", "developedOrder", "developedSale", "statsDate" },
                                "|$|", new DevelopPropertySetter<BiStaffRecommendSaleDayEntity>()),
                        null, new BatchUpdateAction<BiStaffRecommendSaleDayEntity>("biStaffRecommendSaleDay.replace")),
                false);
    }

    /**
     * 2708 bi_staff_arrive_sale_day
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStaffArriveSaleDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffArriveSaleDayEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffArriveSaleDayEntity>(BiStaffArriveSaleDayEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developNum",
                                        "developedNum", "developedOrder", "developedSale", "statsDate" },
                                "|$|", new DevelopPropertySetter<BiStaffArriveSaleDayEntity>()),
                        null, new BatchUpdateAction<BiStaffArriveSaleDayEntity>("biStaffArriveSaleDay.replace")),
                false);
    }

    /**
     * 2709 <br/>
     * 【bi_staff_developing_activity_sale_month】
     */
    @Override
    public void downloadBIStaffDevelopingActivitySaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStaffDevelopingActivitySaleMonthEntity.class, "|@|\n",
                new DefaultLineMapper<BiStaffDevelopingActivitySaleMonthEntity>(
                        BiStaffDevelopingActivitySaleMonthEntity.class,
                        new String[] { "staffId", "staffName", "storeCode", "storeName", "activityCode", "developNum",
                                "developedNum", "developedOrder", "developedSale", "statsMonthOfYear" },
                        "|$|", new DevelopPropertySetter<BiStaffDevelopingActivitySaleMonthEntity>()),
                null, new BatchUpdateAction<BiStaffDevelopingActivitySaleMonthEntity>(
                        "biStaffDevelopingActivitySaleMonth.replace")),
                false);
    }

    /**
     * 2710 <br/>
     * 【BI_STAFF_DEVELOPING_SALE_MONTH】
     */
    @Override
    public void downloadBIStaffDevelopingSaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffDevelopingSaleMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffDevelopingSaleMonthEntity>(BiStaffDevelopingSaleMonthEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developNum",
                                        "developedNum", "developedOrder", "developedSale", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStaffDevelopingSaleMonthEntity>()),
                        null,
                        new BatchUpdateAction<BiStaffDevelopingSaleMonthEntity>("biStaffDevelopingSaleMonth.replace")) {
                }, false);
    }

    /**
     * 2711 <br/>
     * 【BI_STORE_DEVELOPING_SALE_MONTH】
     */
    @Override
    public void downloadBIStoreDevelopingSaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreDevelopingSaleMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStoreDevelopingSaleMonthEntity>(BiStoreDevelopingSaleMonthEntity.class,
                                new String[] { "storeCode", "storeName", "developNum", "developedNum", "developedOrder",
                                        "developedSale", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStoreDevelopingSaleMonthEntity>()),
                        null,
                        new BatchUpdateAction<BiStoreDevelopingSaleMonthEntity>("biStoreDevelopingSaleMonth.replace")),
                false);
    }

    /**
     * 2712<br/>
     * 【bi_store_developing_activity_sale_month】
     */
    @Override
    public void downloadBIStoreDevelopingActivitySaleMonth(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreDevelopingActivitySaleMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStoreDevelopingActivitySaleMonthEntity>(
                                BiStoreDevelopingActivitySaleMonthEntity.class,
                                new String[] { "storeCode", "storeName", "activityCode", "developNum", "developedNum",
                                        "developedOrder", "developedSale", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStoreDevelopingActivitySaleMonthEntity>()),
                        null, new BatchUpdateAction<BiStoreDevelopingActivitySaleMonthEntity>(
                                "biStoreDevelopingActivitySaleMonth.replace")),
                false);
    }

    /**
     * 2713 <br/>
     * 【bi_staff_develop_month】
     */
    @Override
    public void downloadBIStaffDevelopMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffDevelopMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffDevelopMonthEntity>(BiStaffDevelopMonthEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developingNum",
                                        "arriveNum", "followNum", "recommendNum", "statsMonthOfYear", "developedSale" },
                                "|$|", new DevelopPropertySetter<BiStaffDevelopMonthEntity>()),
                        null, new BatchUpdateAction<BiStaffDevelopMonthEntity>("biStaffDevelopMonth.replace")),
                false);
    }

    /**
     * 2714 <br/>
     * 【bi_staff_develop_week】
     */
    @Override
    public void downloadBIStaffDevelopWeek(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffDevelopWeekEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffDevelopWeekEntity>(BiStaffDevelopWeekEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developingNum",
                                        "arriveNum", "followNum", "recommendNum", "statsWeekOfYear", "developedSale" },
                                "|$|", new DevelopPropertySetter<BiStaffDevelopWeekEntity>()),
                        null, new BatchUpdateAction<BiStaffDevelopWeekEntity>("biStaffDevelopWeek.replace")),
                false);
    }

    /**
     * 2715 <br/>
     * 【bi_staff_develop_day】
     */
    @Override
    public void downloadBIStaffDevelopDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStaffDevelopDayEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStaffDevelopDayEntity>(BiStaffDevelopDayEntity.class,
                                new String[] { "staffId", "staffName", "storeCode", "storeName", "developingNum",
                                        "arriveNum", "followNum", "recommendNum", "statsDate", "developedSale" },
                                "|$|", new DevelopPropertySetter<BiStaffDevelopDayEntity>()),
                        null, new BatchUpdateAction<BiStaffDevelopDayEntity>("biStaffDevelopDay.replace")),
                false);
    }

    /**
     * 2716 <br/>
     * 【bi_store_develop_day】
     */
    @Override
    public void downloadBIStoreDevelopDay(String remoteDirectory, String date, String fileName) throws IOException {
        // sqlMap_BiStoreCateRetGdsMonth.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreDevelopDayEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStoreDevelopDayEntity>(BiStoreDevelopDayEntity.class,
                                new String[] { "storeCode", "storeName", "developingNum", "arriveNum", "followNum",
                                        "recommendNum", "statsDate" },
                                "|$|", new DevelopPropertySetter<BiStoreDevelopDayEntity>()),
                        null, new BatchUpdateAction<BiStoreDevelopDayEntity>("biStoreDevelopDay.replace")),
                false);
    }

    /**
     * 2717 <br/>
     * 【bi_store_develop_week】
     */
    @Override
    public void downloadBIStoreDevelopWeek(String remoteDirectory, String date, String fileName) throws IOException {
        // sqlMap_BiStoreCateRetGdsMonth.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreDevelopWeekEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStoreDevelopWeekEntity>(BiStoreDevelopWeekEntity.class,
                                new String[] { "storeCode", "storeName", "developingNum", "arriveNum", "followNum",
                                        "recommendNum", "statsWeekOfYear" },
                                "|$|", new DevelopPropertySetter<BiStoreDevelopWeekEntity>()),
                        null, new BatchUpdateAction<BiStoreDevelopWeekEntity>("biStoreDevelopWeek.replace")),
                false);
    }

    
    /**
     * 36 BI_STORE_CATE_BRAND_MONTH
     */
    @Override
    public void downloadBIStoreCateBrandMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreCateBrandMonth.class, "|@|\n",
                        new DefaultLineMapper<BiStoreCateBrandMonth>(BiStoreCateBrandMonth.class,
                                new String[] {"saleVolume","saleAmount","brandCode","cateCode","brandName","storeCode","storeName","disCode",
                            "disName","saleMonth","updateTime","lastYearSaleAmount","lastYearVolume","positiveSaleVolume","positiveSaleAmount","negativeSaleVolume","negativeSaleAmount",
                            "rank","orgCd","orgName","jxcAmount","lastYearJxcAmount" },
                                "|$|", new SalePropertySetterEx<BiStoreCateBrandMonth>()),
                        null, new BatchUpdateAction<BiStoreCateBrandMonth>("BI_STORE_CATE_BRAND_MONTH.REPLACE")),
                false);
    }
    
    /**
     * 37 BI_STORE_CATE_BRAND_DAY
     */
    @Override
    public void downloadBIStoreCateBrandDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreCateBrandDay.class, "|@|\n",
                        new DefaultLineMapper<BiStoreCateBrandDay>(BiStoreCateBrandDay.class,
                                new String[] {"saleVolume","saleAmount","brandCode","cateCode","brandName","storeCode","storeName","disCode",
                            "disName","saleDate","updateTime","lastYearSaleAmount","lastYearSaleVolume","positiveSaleVolume","positiveSaleAmount","negativeSaleVolume","negativeSaleAmount",
                            "rank","orgCd","orgName","jxcAmount","lastYearJxcAmount" },
                                "|$|", new SalePropertySetterEx<BiStoreCateBrandDay>()),
                        null, new BatchUpdateAction<BiStoreCateBrandDay>("BI_STORE_CATE_BRAND_DAY.REPLACE")),
                false);
    }

    
    /**
     * 38 BI_STORE_CATE_BRAND_MONTH_LAST_YEAR
     */
    @Override
    public void downloadBIStoreCateBrandMonthTOP1(String remoteDirectory, String date, String fileName)
            throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreCateBrandMonthTop1.class, "|@|\n",
                        new DefaultLineMapper<BiStoreCateBrandMonthTop1>(BiStoreCateBrandMonthTop1.class,
                                new String[] {"saleVolume","saleAmount","brandCode","cateCode","brandName","storeCode","storeName","disCode",
                            "disName","saleDate","updateTime","positiveSaleVolume","positiveSaleAmount","negativeSaleVolume","negativeSaleAmount",
                            "ranking"},
                                "|$|", new SalePropertySetterEx<BiStoreCateBrandMonthTop1>()),
                        null, new BatchUpdateAction<BiStoreCateBrandMonthTop1>("BI_STORE_CATE_BRAND_MONTH_LAST_YEAR.REPLACE")),
                false);
    
        
    }
    
    /**
     * 2718<br/>
     * 【bi_store_develop_month】
     */
    @Override
    public void downloadBIStoreDevelopMonth(String remoteDirectory, String date, String fileName) throws IOException {
        // sqlMap_BiStoreCateRetGdsMonth.xml
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BiStoreDevelopMonthEntity.class, "|@|\n",
                        new DefaultLineMapper<BiStoreDevelopMonthEntity>(BiStoreDevelopMonthEntity.class,
                                new String[] { "storeCode", "storeName", "developingNum", "arriveNum", "followNum",
                                        "recommendNum", "statsMonthOfYear" },
                                "|$|", new DevelopPropertySetter<BiStoreDevelopMonthEntity>()),
                        null, new BatchUpdateAction<BiStoreDevelopMonthEntity>("biStoreDevelopMonth.replace")),
                false);
    }

    /**
     * 2901【BI_STORE_GENERAL_OOS,BI_STORE_MAIN_PUSH_OOS,BI_STORE_HOT_OOS】
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStoreOos(String remoteDirectory, String date, String fileName) throws IOException {
        dbBIDeleteJob.deleteOos();
        final LocalDate localDate = new TodaySupplier(date).get();
        Map<String, Action<BiStoreOosEntity>> actions = Maps.newHashMap();
        actions.put("0", new BatchUpdateAction<BiStoreOosEntity>("biStoreGeneralOos.replace"));
        actions.put("1", new BatchUpdateAction<BiStoreOosEntity>("biStoreHotOos.replace"));
        actions.put("2", new BatchUpdateAction<BiStoreOosEntity>("biStoreMainPushOos.replace"));
        ShardedLineMapper<BiStoreOosEntity> lineMapper = new ShardedLineMapper<BiStoreOosEntity>("channel_type",
                BiStoreOosEntity.class,
                new String[] { "storeCode", "storeName", "brand9code", "brand4code", "brandName", "cateCode",
                        "oosGdsNum", "gdsNum", "pv", "uv", "channel_type" },
                "|$|", new AbstractPropertySetter<BiStoreOosEntity>() {
                    @Override
                    protected Optional<Object> property(String name, String value) throws Exception {
                        return Optional.absent();
                    }
                }) {
            @Override
            protected String shardKey(String shardValue) {
                return shardValue;
            }
        };
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new MultiContextWithDefinition(
                BiStoreOosEntity.class, "|@|\n", lineMapper, new BIDataCleanService<BiStoreOosEntity>() {
                    @Override
                    public boolean clean(BiStoreOosEntity obj) {
                        // obj.setBrand4code(obj.getBrand9code().substring(5, 9));
                        return true;
                    }
                }, actions), false);

    }

    /**
     * 2902【BI_STORE_OOS_DETAIL】
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStoreOosDetail(String remoteDirectory, String date, String fileName) throws IOException {
        dbBIDeleteJob.deleteOosDetail();
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreOosDetailEntity.class, "|@|\n",
                new DefaultLineMapper<BiStoreOosDetailEntity>(BiStoreOosDetailEntity.class,
                        new String[] { "storeCode", "storeName", "commCode", "commName", "brand9code", "brand4code",
                                "brandName", "cateCode", "todayUv", "todayPv", "near30SaleVolume", "near30AvgPrice",
                                "cateSaleVolumeRank", "cateSaleAmountRank", "mainPushFlg", "hotSaleFlg" },
                        "|$|", new AbstractPropertySetter<BiStoreOosDetailEntity>() {
                            @Override
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if (name.endsWith("Volume")) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else {
                                    return Optional.absent();
                                }
                            }
                        }),
                new BIDataCleanService<BiStoreOosDetailEntity>() {
                    @Override
                    public boolean clean(BiStoreOosDetailEntity obj) {
                        // obj.setBrand4code(obj.getBrand9code().substring(5, 9));
                        return true;
                    }
                }, new BatchUpdateAction<BiStoreOosDetailEntity>("biStoreOosDetail.replace")), false);
    }

    /**
     * dj30 【BiStoreRealIncDetailMEntity】 提成明细<br/>
     * 
     * 【bi_store_real_inc_detail_m】
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIStoreRealIncDetailM(String remoteDirectory, String date, String fileName) throws IOException {
        // 全表删除提成
        dbBIDeleteJob.deleteBiStoreRealIncDetail();
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreRealIncDetailMEntity.class, "|@|\n",
                new DefaultLineMapper<BiStoreRealIncDetailMEntity>(BiStoreRealIncDetailMEntity.class,
                        new String[] { "incMonth", "orderLocalDate", "orderLocalTime", "employeeCd", "employeeNm",
                                "strCd", "strNm", "omsOrderId", "omsOrderItemId", "posOrderItemId", "saleChannel",
                                "gdsCd", "gdsNm", "brandCd", "brandNm", "partnumberAmt", "payAmt", "saleQty" },
                        "|$|", new AbstractPropertySetter<BiStoreRealIncDetailMEntity>() {
                            @Override
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("payAmt".equals(name)) {
                                    return Optional
                                            .of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_DOWN));
                                } else if ("saleQty".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                }
                                return Optional.absent();
                            }
                        }),
                new BIDataCleanService<BiStoreRealIncDetailMEntity>() {
                    @Override
                    public boolean clean(BiStoreRealIncDetailMEntity obj) {
                        DateTime dateTime = new DateTime();
                        dateTime = dateTime.withDate(
                                LocalDate.parse(obj.getOrderLocalDate(), DateTimeFormat.forPattern("yyyyMMdd")));
                        dateTime = dateTime.withTime(
                                LocalTime.parse(obj.getOrderLocalTime(), DateTimeFormat.forPattern("HHmmss")));
                        obj.setOrderTime(dateTime.toDate());
                        return true;
                    }
                }, new BatchUpdateAction<BiStoreRealIncDetailMEntity>("biStoreRealIncDetailM.replace")), false);
    }

    /**
     * [A1000024] storeRegMemberDetailD<br/>
     * 【store_reg_member_detail_d】
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadStoreRegMemberDetailD(String remoteDirectory, String date, String fileName) throws IOException {

        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get().minusDays(1);
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(StoreRegMemberDetailDEntity.class, "|@|\n",
                        new DefaultLineMapper<StoreRegMemberDetailDEntity>(StoreRegMemberDetailDEntity.class,
                                new String[] { "statisDate", "memberId", "employeeCd", "employeeNm", "strCd", "strNm",
                                        "cmpnyCd", "cmpnyNm", "memberSourceCd", "memberSourceNm", "offlineCreateTime",
                                        "offlineChnlCd", "onlineCreateTime", "onlineChnlCd" },
                                "|$|", new AbstractPropertySetter<StoreRegMemberDetailDEntity>("-") {
                                    Set<String> timeStrs = Sets.newHashSet("offlineCreateTime", "onlineCreateTime");

                                    @Override
                                    protected Optional<Object> property(String name, String value) throws Exception {
                                        if (timeStrs.contains(name)) {
                                            return Optional.of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
                                                    .parse(value));
                                        }
                                        return Optional.absent();
                                    }
                                }),
                        new BIDataCleanService<StoreRegMemberDetailDEntity>() {
                            @Override
                            public boolean clean(StoreRegMemberDetailDEntity obj) {
                                return true;
                            }
                        },
                        new ListeningAction<StoreRegMemberDetailDEntity>(
                                new BatchUpdateAction<StoreRegMemberDetailDEntity>("storeRegMemberDetailD.replace"),
                                asyncListener)),
                false);
    }

    /**
     * #31【sale_no_pick_order】
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBISaleNoPickOrder(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        Map<String, Action<BISaleNoPickOrderEntity>> actions = Maps.newHashMap();
        actions.put("1", new BatchUpdateAction<BISaleNoPickOrderEntity>("biSaleNoPickOrder.replace"));
        actions.put("-1", new BatchUpdateAction<BISaleNoPickOrderEntity>("biSaleNoPickOrder.delete"));
        ShardedLineMapper<BISaleNoPickOrderEntity> lineMapper = new ShardedLineMapper<BISaleNoPickOrderEntity>("type",
                BISaleNoPickOrderEntity.class,
                new String[] { "type", "storeCode", "staffId", "staffName", "posOrderId", "orderItemId", "saleNum",
                        "payAmount", "cateCode", "brandCode", "brandName", "orderTime", "commCode", "commName",
                        "custName", "custMobile", "address" },
                "|$|", new AbstractPropertySetter<BISaleNoPickOrderEntity>() {
                    protected Optional<Object> property(String name, String value) throws Exception {
                        if (Sets.newHashSet("saleNum").contains(name)) {
                            return Optional.of((Object) new BigDecimal(value).intValue());
                        } else if ("payAmount".equals(name)) {
                            return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                        } else if ("orderTime".equals(name)) {
                            return Optional.of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                        }
                        return Optional.absent();
                    }
                }) {
            @Override
            protected String shardKey(String shardValue) {
                return shardValue;
            }
        };
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new MultiContextWithDefinition(BISaleNoPickOrderEntity.class, "|@|\n", lineMapper, null, actions),
                false);
    }

    /**
     * #2804【model_analyse】
     * 
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws IOException
     */
    @Override
    public void downloadBIModelAnalyse(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        dbBIDeleteJob.deleteBIModelAnalyse();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIModelAnalyseEntity.class, "|@|\n",
                        new DefaultLineMapper<BIModelAnalyseEntity>(BIModelAnalyseEntity.class,
                                new String[] { "disCode", "disName", "orgCode", "orgName", "storeCode", "storeName",
                                        "storeType", "cateCode", "cateName", "branchCode", "branchName", "saleNum",
                                        "saleAmount", "validNum", "updateTime" },
                                "|$|", new AbstractPropertySetter<BIModelAnalyseEntity>() {
                                    protected Optional<Object> property(String name, String value) throws Exception {
                                        if (Sets.newHashSet("saleNum", "validNum").contains(name)) {
                                            return Optional.of((Object) new BigDecimal(value).intValue());
                                        } else if ("saleAmount".equals(name)) {
                                            return Optional.of(
                                                    (Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                        } else if ("updateTime".equals(name)) {
                                            return Optional.of(
                                                    (Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                        }
                                        return Optional.absent();
                                    }
                                }),
                        null, new BatchUpdateAction<BIModelAnalyseEntity>("biModelAnalyse.replace")),
                false);
    }

    /**
     * #2805 【sale_analyse】
     * 
     * @throws Exception
     */
    @Override
    public void downloadBISaleAnalyse(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();

        dbBIDeleteJob.deleteBISaleAnalyse();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BISaleAnalyseEntity.class, "|@|\n",
                new DefaultLineMapper<BISaleAnalyseEntity>(BISaleAnalyseEntity.class,
                        new String[] { "disCode", "disName", "orgCode", "orgName", "storeCode", "storeName",
                                "storeType", "cateCode", "cateName", "branchCode", "branchName", "saleNum",
                                "saleAmount", "updateTime" },
                        "|$|", new AbstractPropertySetter<BISaleAnalyseEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if (Sets.newHashSet("saleNum", "validNum").contains(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("saleAmount".equals(name)) {
                                    return Optional
                                            .of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("updateTime".equals(name)) {
                                    return Optional
                                            .of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new BatchUpdateAction<BISaleAnalyseEntity>("biSaleAnalyse.replace")), false);
    }

    /**
     * 2806 model_recommend
     */
    @Override
    public void downloadBIModelRecommend(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        dbBIDeleteJob.deleteBIModelRecommend();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIModelRecommendEntity.class, "|@|\n",
                new DefaultLineMapper<BIModelRecommendEntity>(BIModelRecommendEntity.class,
                        new String[] { "disCode", "disName", "orgCode", "orgName", "storeCode", "storeName", "cateCode",
                                "cateName", "branchCode", "branchName", "saleNum", "commCode", "commName",
                                "updateTime" },
                        "|$|", new AbstractPropertySetter<BIModelRecommendEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("saleNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("updateTime".equals(name)) {
                                    return Optional
                                            .of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new BatchUpdateAction<BIModelRecommendEntity>("biModelRecommend.replace")), false);
    }
    
    /**
     * 2801_01 文件：o2o_dianjia_model_company_recommend 表：MODEL_COMPANY_RECOMMEND 样机推荐-分公司（根据大区热销商品）
     */
    @Override
    public void downloadBIModelCompanyRecommend(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        dbBIDeleteJob.deleteBIModelCompanyRecommend();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIModelRecommendEntity.class, "|@|\n",
                new DefaultLineMapper<BIModelRecommendEntity>(BIModelRecommendEntity.class,
                        new String[] { "disCode", "disName", "orgCode", "orgName", "cateCode",
                                "cateName", "branchCode", "branchName", "saleNum", "commCode", "commName",
                                "updateTime" },
                        "|$|", new AbstractPropertySetter<BIModelRecommendEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("saleNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("updateTime".equals(name)) {
                                    return Optional
                                            .of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new BatchUpdateAction<BIModelRecommendEntity>("biModelCompanyRecommend.replace")), false);
    }
    
    /**
     * 2801_02 文件：o2o_dianjia_model_area_recommend 表：MODEL_AREA_RECOMMEND 样机推荐-大区（根据全国热销商品）AREA_
     */
    @Override
    public void downloadBIModelAreaRecommend(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        dbBIDeleteJob.deleteBIModelAreaRecommend();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIModelRecommendEntity.class, "|@|\n",
                new DefaultLineMapper<BIModelRecommendEntity>(BIModelRecommendEntity.class,
                        new String[] { "disCode", "disName", "cateCode",
                                "cateName", "branchCode", "branchName", "saleNum", "commCode", "commName",
                                "updateTime" },
                        "|$|", new AbstractPropertySetter<BIModelRecommendEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("saleNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("updateTime".equals(name)) {
                                    return Optional
                                            .of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new BatchUpdateAction<BIModelRecommendEntity>("biModelAreaRecommend.replace")), false);
    }

    /**
     * #2807 MODEL_SALE_TOP
     */
    @Override
    public void downloadBIModelSaleTop(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        dbBIDeleteJob.deleteBIModelSaleTop();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIModelSaleTopEntity.class, "|@|\n",
                new DefaultLineMapper<BIModelSaleTopEntity>(BIModelSaleTopEntity.class,
                        new String[] { "disCode", "disName", "orgCode", "orgName", "storeCode", "storeName", "cateCode",
                                "cateName", "branchCode", "branchName", "saleNum", "commCode", "commName", "flag",
                                "updateTime" },
                        "|$|", new AbstractPropertySetter<BIModelSaleTopEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("saleNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("updateTime".equals(name)) {
                                    return Optional
                                            .of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new BatchUpdateAction<BIModelSaleTopEntity>("biModelSaleTop.replace")), false);
    }

    @Override
    public void downloadBIIndexTaskCard(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final String bizKey = "10002";// 预定义的固定值
        final String cardType = "002";// 预定义传固定值
        dbBIDeleteJob.deleteBIIndexTaskCard(bizKey);
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate,
                new SimpleContextWithDefinition(BIIndexTaskCardEntity.class, "|@|\n",
                        new DefaultLineMapper<BIIndexTaskCardEntity>(BIIndexTaskCardEntity.class,
                                new String[] { "staffId", "firstNum" }, "|$|",
                                new AbstractPropertySetter<BIIndexTaskCardEntity>() {
                                    protected Optional<Object> property(String name, String value) throws Exception {
                                        if ("firstNum".equals(name)) {
                                            return Optional.of((Object) (new BigDecimal(value).intValue() + ""));
                                        }
                                        return Optional.absent();
                                    }
                                }),
                        new BIDataCleanService<BIIndexTaskCardEntity>() {
                            private MessageFormat mf = new MessageFormat("您还有{0}笔订单未完成送货");

                            @Override
                            public boolean clean(BIIndexTaskCardEntity obj) {
                                // 数据组装
                                LocalDate nowDay = new LocalDate();
                                obj.setBizKey(bizKey);
                                obj.setCardType(cardType);
                                obj.setTitle("已销未提");
                                obj.setStartTime(nowDay.toDate());
                                // 默认时间为一年
                                obj.setEndTime(nowDay.plusYears(1).toDate());
                                obj.setTaskTips(mf.format(new Object[] { obj.getFirstNum() }));
                                return true;
                            }
                        }, new BatchUpdateAction<BIIndexTaskCardEntity>("biIndexTaskCard.replace")),
                false);
    }

    private class DevelopPropertySetter<T> extends AbstractPropertySetter<T> {
        @Override
        protected Optional<Object> property(String name, String value) throws Exception {
            if (name.endsWith("Num") || name.endsWith("Volume")) {
                return Optional.of((Object) new BigDecimal(value).intValue());
            } else if (name.endsWith("Amount")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            } else {
                return Optional.absent();
            }
        }
    }

    private class SalePropertySetter<T> extends AbstractPropertySetter<T> {
        @Override
        protected Optional<Object> property(String name, String value) throws Exception {
            if ("saleVolume".equals(name)) {
                return Optional.of((Object) new BigDecimal(value).intValue());
            } else if ("updateTime".equals(name)) {
                return Optional.of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
            } else if (name.endsWith("Amount")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            } else if (name.endsWith("Price")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            } else if (name.endsWith("Rate")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            } else {
                return Optional.absent();
            }
        }
    }
    
    private class SalePropertySetterEx<T> extends AbstractPropertySetter<T> {
        @Override
        protected Optional<Object> property(String name, String value) throws Exception {
            if (name.endsWith("Volume")) {
                return Optional.of((Object) new BigDecimal(value).intValue());
            } else if ("updateTime".equals(name)) {
                return Optional.of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
            } else if (name.endsWith("Amount")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            } else if (name.endsWith("Price")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            } else if (name.endsWith("Rate")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            }  else if (name.startsWith("rank")) {
                return Optional.of((Object) new BigDecimal(value).intValue());
            } else {
                return Optional.absent();
            }
        }
    }
    

    /**
     * "rank", "retGdsRate", "retGdsNum", "refund", "lastMonRetGdsNum", "lastMonRefund", "lastYearRetGdsNum",
     * "lastYearRefund", "saleVolume", "saleAmount", "lastMonSaleVolume", "lastMonSaleAmount", "lastYearSaleVolume",
     * "lastYearSaleAmount", "storeCode", "storeName", "disCode", "disName", "statisDate", "month", "year"
     * 
     * @author 13071602
     *
     * @param <T>
     */
    private class RefundSalePropertySetter<T> extends AbstractPropertySetter<T> {
        @Override
        protected Optional<Object> property(String name, String value) throws Exception {
            if (name.endsWith("Num") || name.endsWith("Volume")) {
                return Optional.of((Object) new BigDecimal(value).intValue());
            } else if (name.endsWith("Amount")) {
                return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
            } else {
                return Optional.absent();
            }
        }
    }

    private class BIStaffDataCleanService<T extends StaffInfoAware> implements BIDataCleanService<T> {
        @Override
        public boolean clean(T obj) {
            if (StringUtils.isNotEmpty(obj.getStaffId())) {
                // 截取后 8 位工号
                int beginIndex = obj.getStaffId().length() - 8;
                obj.setStaffId(obj.getStaffId().substring(beginIndex > 0 ? beginIndex : 0));
            }
            return true;
        }
    }

    /**
     * 批量入库
     * 
     * @author 13071602
     *
     * @param <T>
     */
    private class BatchUpdateAction<T> implements Action<T> {

        private String sqlId;

        public BatchUpdateAction(String sqlId) {
            this.sqlId = sqlId;
        }

        @SuppressWarnings("unchecked")
        @Override
        public void action(T[] objs) {
            Map<String, Object>[] batchValues = Iterables
                    .toArray(Iterables.transform(Lists.newArrayList(objs), new Function<T, Map<String, Object>>() {
                        @Override
                        public Map<String, Object> apply(T input) {
                            return new BeanMap(input);
                        }
                    }), Map.class);
            batchUpdateService.batchUpdate(sqlId, batchValues);
        }
    }

    /**
     * 上传门店数据
     */
    @Override
    public void uploadStoreInfo(String remoteDirectory, String date, String fileName) {
        LOGGER.info("uploadMainDiscode enter, remoteDirectory={},date={},fileName={}",
                new Object[] { remoteDirectory, date, fileName });
        final String lineSeparator = "|@|\n";
        final LocalDate localDate = new TodaySupplier(date).get();
        // 查询所有门店
        List<StoreInfo> stores = storeInfoService.queryAllStore();
        List<MainDiscodeDto> discodes = mainDiscodeService.queryMainDiscode();
        // 数据不为空时
        if (CollectionUtils.isNotEmpty(stores) && CollectionUtils.isNotEmpty(discodes)) {
            // 将集合转换成MAP,方便取对象
            final Map<String, MainDiscodeDto> mappedDiscode = Maps.uniqueIndex(discodes,
                    new Function<MainDiscodeDto, String>() {
                        public String apply(MainDiscodeDto from) {
                            return from.getDisCode();
                        }
                    });
            LOGGER.debug("uploadMainDiscode uploadBIFILE size={}", stores.size());
            // FTP工具上传文件
            ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator, stores.iterator(),
                    new Function<StoreInfo, String>() {
                        @Override
                        public String apply(StoreInfo row) {
                            // 获取门店行信息
                            return getStoreString(row, mappedDiscode);
                        }
                    }, -1);
        }
        LOGGER.info("uploadMainDiscode exit, remoteDirectory={},date={},fileName={}",
                new Object[] { remoteDirectory, date, fileName });
    }

    /**
     * 拼接门店属性字符串行信息 功能描述: <br>
     * 〈功能详细描述〉
     *
     * @param row
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    private String getStoreString(StoreInfo row, Map<String, MainDiscodeDto> mappedDiscode) {
        StringBuilder cache = new StringBuilder();
        // 门店编码
        cache.append(getNotNullString(row.getStoreCode()));
        // 门店名称
        cache.append("|$|").append(getNotNullString(row.getStoreName()));
        // 门店级别
        cache.append("|$|").append(getNotNullString(row.getStoreLevel()));
        // 分公司编码
        cache.append("|$|").append(getNotNullString(row.getBranchCode()));
        // 分公司名称
        cache.append("|$|").append(getNotNullString(row.getBranchName()));
        // 8位大区编码, 转换成5位大区编码
        MainDiscodeDto main = mappedDiscode.get(row.getRegionCode());
        if (null != main) {
            // 设置5位大区编码
            cache.append("|$|").append(getNotNullString(main.getDisCodeFive()));
        } else {
            // 默认空字符串
            cache.append("|$|").append("");
        }
        // 大区编码 8位
        cache.append("|$|").append(getNotNullString(row.getRegionCode()));
        // 大区名称
        cache.append("|$|").append(getNotNullString(row.getRegionName()));
        // 门店类型编码
        cache.append("|$|").append(getNotNullString(row.getStoreTypeCode()));
        // 门店类型名称
        cache.append("|$|").append(getNotNullString(row.getStoreTypeName()));
        // 城市编码 4位
        cache.append("|$|").append(getNotNullString(row.getCityComCode()));
        // 城市名称
        cache.append("|$|").append(getNotNullString(row.getCityComName()));
        // 分公司财务编码 4位
        cache.append("|$|").append(getNotNullString(row.getSaleBranchCode()));
        return cache.toString();
    }

    /**
     * 非空字符串 功能描述: <br>
     * 〈功能详细描述〉
     *
     * @param str
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    private String getNotNullString(String str) {
        if (StringUtils.isBlank(str)) {
            return "";
        }
        return str;
    }

    /**
     *  #2808 tmp_dianjia_model_sale_store_cate 
     *  MODEL_ANALYSE_IN
     * 保存后台样机分析数据
     */
    @Override
    public void downloadBISaleAnalyseIn(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiModelAnalyseInEntity.class, "|@|\n",
                new DefaultLineMapper<BiModelAnalyseInEntity>(BiModelAnalyseInEntity.class,
                        new String[] { "saleMonth", "disCode", "disName", "branchCode", "branchName", "storeCode", "storeName", "cateCode",
                                "cateName", "saleNum", "saleAmount", "validNum", "modelTotal", "updateTime" },
                        "|$|", new AbstractPropertySetter<BiModelAnalyseInEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("saleNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("validNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("modelTotal".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("saleAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP).toString());
                                } else if ("updateTime".equals(name)) {
                                    return Optional
                                            .of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new BatchUpdateAction<BiModelAnalyseInEntity>("biModelAnalyse.SAVE_IN")), false);
        
    }

    /**
     *  #2809 tmp_dianjia_model_sale_commodity_details
     *  MODEL_SALE_TOP_IN
     * 保存后台样机销售排行榜
     */
    @Override
    public void downloadBIModelSaleTopIn(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除上月数据
        dbBIDeleteJob.deleteBIModelSaleTopIn(DateUtils.getLastMonth());
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiModelSaleTopInEntity.class, "|@|\n",
                new DefaultLineMapper<BiModelSaleTopInEntity>(BiModelSaleTopInEntity.class,
                        new String[] { "saleMonth", "cateCode", "cateName", "brandCode", "brandName", "commCode", 
                                "commName", "saleNum", null, "modelTotal", "modelCnt", "validNum", "updateTime" },
                        "|$|", new AbstractPropertySetter<BiModelSaleTopInEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("saleNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("modelCnt".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("modelTotal".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("validNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("updateTime".equals(name)) {
                                    return Optional
                                            .of((Object) new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new BatchUpdateAction<BiModelSaleTopInEntity>("biModelSaleTop.SAVE_IN")), false);
        
    }

    @Override
    public void downloadStoreMonSaleTask(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreMonSaleTask.class, "|@|\n", new DefaultLineMapper<BiStoreMonSaleTask>(
                        BiStoreMonSaleTask.class, new String[]{"storeCode", "taskSaleAmount", "taskGrossProfit"
                            , null, null, null, null, null, null
                            , null, null, "month", null}, "|$|", new AbstractPropertySetter<BiStoreMonSaleTask>(){
                            @Override
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("taskSaleAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("taskGrossProfit".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                }
                                return Optional.absent();
                            }
                            
                        }), null, new BatchUpdateAction<BiStoreMonSaleTask>("BI_STORE_MON_SALE_TASK.REPLACE")), false);
        
    }

    @Override
    public void downloadStoreCateMonSaleTask(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreCateMonSaleTask.class, "|@|\n", new DefaultLineMapper<BiStoreCateMonSaleTask>(
                        BiStoreCateMonSaleTask.class, new String[]{"storeCode", "cateCode", "taskSaleAmount", "taskGrossProfit"
                            , null, null, null, null, null, null
                            , null, null, "month"}, "|$|", new AbstractPropertySetter<BiStoreCateMonSaleTask>(){
                            @Override
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("taskSaleAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("taskGrossProfit".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                }
                                return Optional.absent();
                            }
                            
                        }), null, new BatchUpdateAction<BiStoreCateMonSaleTask>("BI_STORE_CATE_MON_SALE_TASK.REPLACE")), false);
        
    }

    @Override
    public void downLoadStoreMonRealSale(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreMonSaleTask.class, "|@|\n", new DefaultLineMapper<BiStoreMonSaleTask>(
                        BiStoreMonSaleTask.class, new String[]{"storeCode", "taskSaleAmount", "taskGrossProfit"
                            , "saleAmount", "grossProfit", "jxce", "grossProfitRate", "saleCompleteRate", "saleRateRank"
                            , "grossCompleteRate", "grossRateRank", "month", "etlTime"}, "|$|", new AbstractPropertySetter<BiStoreMonSaleTask>(){
                            @Override
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("taskSaleAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("taskGrossProfit".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("saleAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("grossProfit".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("jxce".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("grossProfitRate".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(3, RoundingMode.HALF_UP));
                                } else if ("saleCompleteRate".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(3, RoundingMode.HALF_UP));
                                } else if ("saleRateRank".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("grossCompleteRate".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(3, RoundingMode.HALF_UP));
                                } else if ("grossRateRank".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } else if ("etlTime".equals(name)) {
                                    Date date = null;
                                    if (StringUtils.isNotBlank(value)) {
                                        date = DateUtils.getDateByStr(value, DateUtils.DEFAULT_TIME_PATTERN); 
                                    }
                                    return Optional.of((Object) date);
                                }
                                return Optional.absent();
                            }
                        }), null, new BatchUpdateAction<BiStoreMonSaleTask>("BI_STORE_MON_SALE_TASK.UPDATE")), false);
        
    }

    /**
     * 33_1
     */
    @Override
    public void downLoadStoreLastYearSaleDay(String remoteDirectory, String date, String fileName) throws IOException {
        // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除今天之前的数据
        final String today = DateUtils.getDateStrByFormat(new Date(), DateUtils.YYYYMMDD_PATTERN);
        dbBIDeleteJob.deleteStoreLastYearSale(today);
        // 每天跑昨天的数据
        final String statisDate = DateUtils.getDateStrByFormat(DateUtils.getNextDay(new Date(), 1), DateUtils.YYYYMMDD_PATTERN);
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreLastYearSale.class, "|@|\n", new DefaultLineMapper<BiStoreLastYearSale>(
                        BiStoreLastYearSale.class, new String[]{"storeCode", "saleAmount", "statisTime"
                            , "updateTime","saleVloume","custNum","jxcAmount"}, "|$|", new AbstractPropertySetter<BiStoreLastYearSale>(){
                            @Override
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("jxcAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                }if ("saleAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                }if ("saleVloume".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(0, RoundingMode.HALF_UP));
                                }if ("custNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(0, RoundingMode.HALF_UP));
                                } else if ("statisTime".equals(name)) {
                                    String statisTime = value.replaceFirst("^0*", "");
                                    return Optional.of((Object) statisTime);
                                } else if ("updateTime".equals(name)) {
                                    Date date = null;
                                    if (StringUtils.isNotBlank(value)) {
                                        date = DateUtils.getDateByStr(value, DateUtils.DEFAULT_TIME_PATTERN); 
                                    }
                                    return Optional.of((Object) date);
                                }
                                return Optional.absent();
                            }
                        }), new BIDataCleanService<BiStoreLastYearSale>() {

                            @Override
                            public boolean clean(BiStoreLastYearSale obj) {
                                obj.setStatisDate(statisDate);
                                return true;
                            }
                        }, new BatchUpdateAction<BiStoreLastYearSale>("BI_STORE_SALE_REAL_TIME.UPSERT_STORE_LAST_YEAR_SALE")), false);
        
    }

    /**
     * 33_2
     */
    @Override
    public void downLoadStoreCateLastYearSaleDay(String remoteDirectory, String date, String fileName)
            throws IOException {
     // 默认放在昨日的文件夹里面
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除今天之前的数据
        final String today = DateUtils.getDateStrByFormat(new Date(), DateUtils.YYYYMMDD_PATTERN);
        dbBIDeleteJob.deleteStoreCateLastYearSale(today);
        // 每天跑昨天的数据
        final String statisDate = DateUtils.getDateStrByFormat(DateUtils.getNextDay(new Date(), 1), DateUtils.YYYYMMDD_PATTERN);
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BiStoreLastYearSale.class, "|@|\n", new DefaultLineMapper<BiStoreLastYearSale>(
                        BiStoreLastYearSale.class, new String[]{"storeCode", "cateCode", "saleAmount", "statisTime"
                            , "updateTime","saleVloume","custNum","jxcAmount"}, "|$|", new AbstractPropertySetter<BiStoreLastYearSale>(){
                            @Override
                            protected Optional<Object> property(String name, String value) throws Exception {
                                if ("jxcAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                }if ("saleAmount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                }if ("saleVloume".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(0, RoundingMode.HALF_UP));
                                }if ("custNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(0, RoundingMode.HALF_UP));
                                } else if ("statisTime".equals(name)) {
                                    String statisTime = value.replaceFirst("^0*", "");
                                    return Optional.of((Object) statisTime);
                                } else if ("updateTime".equals(name)) {
                                    Date date = null;
                                    if (StringUtils.isNotBlank(value)) {
                                        date = DateUtils.getDateByStr(value, DateUtils.DEFAULT_TIME_PATTERN); 
                                    }
                                    return Optional.of((Object) date);
                                }
                                return Optional.absent();
                            }
                        }), new BIDataCleanService<BiStoreLastYearSale>() {

                            @Override
                            public boolean clean(BiStoreLastYearSale obj) {
                                obj.setStatisDate(statisDate);
                                return true;
                            }
                        }, new BatchUpdateAction<BiStoreLastYearSale>("BI_STORE_SALE_REAL_TIME.UPSERT_STORE_CATE_LAST_YEAR_SALE")), false);
    }

    @Override
    public void uploadYoyDate(String remoteDirectory, String date, String fileName) {
        Date tomorrow = DateUtils.getNextDay(new Date(), 1);
        Date yesterday = DateUtils.getNextDay(new Date(), -1);
        String tomorrowYoyDate = DateUtils.getYoyDate(tomorrow, null);
        String yetdYoyDate = DateUtils.getYoyDate(yesterday, null);
        final LocalDate localDate = new TodaySupplier(date).get();
        List<String[]> lines = new ArrayList<String[]>();
        String[] args = {tomorrowYoyDate, yetdYoyDate};
        lines.add(args);
        // FTP工具上传文件
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, "|@|\n", lines.iterator(),
                new Function<String[], String>() {
                    @Override
                    public String apply(String[] input) {
                        return input[0] + "|$|" + input[1];
                    }
                }, -1);
    }
    
    @Override
    public void downPartyMemberInfo(String remoteDirectory, String date, String fileName) throws IOException {
            // 默认放在昨日的文件夹里面
           final LocalDate localDate = new TodaySupplier(date).get();
           ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                   PtyMemberRecordDto.class, "|@|\n", new DefaultLineMapper<PtyMemberRecordDto>(
                           PtyMemberRecordDto.class, new String[]{"staffId", "storeCode", "custName", "regDate"
                               , "oraLongName",  "mobile","custNum"}, "|$|", new AbstractPropertySetter<PtyMemberRecordDto>(){
                               @Override
                               protected Optional<Object> property(String name, String value) throws Exception {
                                   if ("regDate".equals(name)) {
                                       Date date = null;
                                       if (StringUtils.isNotBlank(value)) {
                                           date = DateUtils.getDateByStr(value, DateUtils.DEFAULY_FULL_TIME_PATTERN); 
                                       }
                                       return Optional.of((Object) date);
                                   }
                                   return Optional.absent();
                               }
                           }), new BIDataCleanService<PtyMemberRecordDto>() {
                               @Override
                               public boolean clean(PtyMemberRecordDto obj) {
                                   obj.setUpdateDate(new Date());
                                   return true;
                               }
                           }, new BatchUpdateAction<PtyMemberRecordDto>("BI_PARTY_MEMBER.UPSERT_SPARTY_MEMBER")), false);
       
    }
    
    
    @Override
    public void downEmployeeHireInfo(String remoteDirectory, String date, String fileName) throws IOException {
    	// 获取指定日期
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除之前数据
        dbBIDeleteJob.deleteEmployeeHireInfo();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
        		BiEmployeeHireInfoEntity.class, "|@|\n",new DefaultLineMapper<BiEmployeeHireInfoEntity>(
        				BiEmployeeHireInfoEntity.class, new String[] { "employeeId", "gender", "hireTime", "hireDay", "hireMonth",
        					"ranking", "countAll", "etlTime" }, "|$|", new AbstractPropertySetter<BiEmployeeHireInfoEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                            	if ("hireTime".equals(name)) {
                                    return Optional.of((Object) DateTime.parse(value, DateTimeFormat.forPattern("yyyy-MM-dd")).toString("yyyy-MM-dd"));
                                }
                                return Optional.absent();
                            }
                        }),
                null, new TmBatchUpdateAction<BiEmployeeHireInfoEntity>("BI_TM.SAVE_EMPLOYEE_HIRE_INFO",batchUpdateService,timeMachineDao,cacheUtils,BiEmployeeHireInfoEntity.class)), false);
    }
    
    
    @Override
    public void downEmployeeFirstSaleInfo(String remoteDirectory, String date, String fileName) throws IOException {
    	// 获取指定日期
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除之前数据
        dbBIDeleteJob.deleteEmployeeFirstSaleInfo();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
        		BiEmployeeFirstSaleInfoEntity.class, "|@|\n",new DefaultLineMapper<BiEmployeeFirstSaleInfoEntity>(
        				BiEmployeeFirstSaleInfoEntity.class, new String[] {null,"payDate", "payTime", "price", "num", "payAmnt",
        					null,"cmmdtyName", "cateCode","employeeId",null, "etlTime" }, "|$|", new AbstractPropertySetter<BiEmployeeFirstSaleInfoEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                            	if ("price".equals(name) || "payAmnt".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("num".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } 
                                return Optional.absent();
                            }
                        }),
                        new BIDataCleanService<BiEmployeeFirstSaleInfoEntity>() {
                            @Override
                            public boolean clean(BiEmployeeFirstSaleInfoEntity obj) {
                                DateTime dateTime = new DateTime();
                                dateTime = dateTime.withDate(
                                        LocalDate.parse(obj.getPayDate(), DateTimeFormat.forPattern("yyyyMMdd")));
                                obj.setSaleDate(dateTime.toString("yyyy-MM-dd"));
                                return true;
                            }
                        }, new TmBatchUpdateAction<BiEmployeeFirstSaleInfoEntity>("BI_TM.SAVE_EMPLOYEE_FIRST_SALE_INFO",batchUpdateService,timeMachineDao,cacheUtils,BiEmployeeFirstSaleInfoEntity.class)), false);
    }
    
    @Override
    public void downEmployeeTotalSaleInfo(String remoteDirectory, String date, String fileName) throws IOException{
    	// 获取指定日期
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除之前数据
        dbBIDeleteJob.deleteEmployeeTotalSaleInfo();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
        		BiEmployeeTotalSaleInfoEntity.class, "|@|\n",new DefaultLineMapper<BiEmployeeTotalSaleInfoEntity>(
        				BiEmployeeTotalSaleInfoEntity.class, new String[] {"employeeId", "amount", "orderNum", "etlTime" }, 
        				"|$|", new AbstractPropertySetter<BiEmployeeTotalSaleInfoEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                            	if ("amount".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                }else if ("orderNum".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } 
                            	
                                return Optional.absent();
                            }
                        }),null, new TmBatchUpdateAction<BiEmployeeTotalSaleInfoEntity>("BI_TM.SAVE_EMPLOYEE_TOTAL_SALE_INFO",batchUpdateService,timeMachineDao,cacheUtils,BiEmployeeTotalSaleInfoEntity.class)), false);
    }

    @Override
    public void downEmployeeExpensiveSaleInfo(String remoteDirectory, String date, String fileName) throws IOException {
    	// 获取指定日期
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除之前数据
        dbBIDeleteJob.deleteEmployeeExpensiveSaleInfo();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
        		BiEmployeeExpensiveSaleInfoEntity.class, "|@|\n",new DefaultLineMapper<BiEmployeeExpensiveSaleInfoEntity>(
        				BiEmployeeExpensiveSaleInfoEntity.class, new String[] { null,"payDate", "payTime", "num", "payAmnt",
        					null,"cmmdtyName", "cateCode","employeeId","customName","gender", "etlTime" }, "|$|", new AbstractPropertySetter<BiEmployeeExpensiveSaleInfoEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                            	if ( "payAmnt".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } else if ("num".equals(name)) {
                                    return Optional.of((Object) new BigDecimal(value).intValue());
                                } 
                                return Optional.absent();
                            }
                        }),
                        new BIDataCleanService<BiEmployeeExpensiveSaleInfoEntity>() {
                            @Override
                            public boolean clean(BiEmployeeExpensiveSaleInfoEntity obj) {
                                DateTime dateTime = new DateTime();
                                dateTime = dateTime.withDate(
                                        LocalDate.parse(obj.getPayDate(), DateTimeFormat.forPattern("yyyyMMdd")));
                                obj.setSaleDate(dateTime.toString("yyyy-MM-dd"));
                                return true;
                            }
                        }, new TmBatchUpdateAction<BiEmployeeExpensiveSaleInfoEntity>("BI_TM.SAVE_EMPLOYEE_EXPENSIVE_SALE_INFO",batchUpdateService,timeMachineDao,cacheUtils,BiEmployeeExpensiveSaleInfoEntity.class)), false);
    }
    
    @Override
    public void downEmployeeCategoryInfo(String remoteDirectory, String date, String fileName) throws IOException {
    	// 获取指定日期
        final LocalDate localDate = new TodaySupplier(date).get();
        // 删除之前数据
        dbBIDeleteJob.deleteEmployeeCategoryInfo();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
        		BiEmployeeCategoryInfoEntity.class, "|@|\n",new DefaultLineMapper<BiEmployeeCategoryInfoEntity>(
        				BiEmployeeCategoryInfoEntity.class, new String[] {"employeeId", "payAmnt00001", "payAmnt00002", "payAmnt00003",
        					"payAmnt00004","payAmnt00005", "payAmnt00006","payAmnt00007","payAmnt00013","payAmntOther","payAmntAll", "etlTime" }, 
        					"|$|", new AbstractPropertySetter<BiEmployeeCategoryInfoEntity>() {
                            protected Optional<Object> property(String name, String value) throws Exception {
                            	if ( name != null && name.startsWith("payAmnt")) {
                                    return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
                                } 
                                return Optional.absent();
                            }
                        }),null, new TmBatchUpdateAction<BiEmployeeCategoryInfoEntity>("BI_TM.SAVE_EMPLOYEE_CATEGORY_INFO",batchUpdateService,timeMachineDao,cacheUtils,BiEmployeeCategoryInfoEntity.class)), false);
    }
    
	@Override
	public void downEmployeeMemberInfo(String remoteDirectory, String date, String fileName) throws IOException {
		// 获取指定日期
		final LocalDate localDate = new TodaySupplier(date).get();
		// 删除之前数据
		String key = TMConstants.TIME_MACHINE_MEMBER_KEY + "*";
		cacheUtils.del(key);
		
		dbBIDeleteJob.deleteEmployeeMemberInfo();
		ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(BiEmployeeMemberInfoEntity.class, "|@|\n",
				new DefaultLineMapper<BiEmployeeMemberInfoEntity>(BiEmployeeMemberInfoEntity.class, new String[] { "employeeId", "memberId", "customName", "gender", "orderNum", "payAmnt",
						"memberNum", "oldMemberNum", "etlTime" }, "|$|", new AbstractPropertySetter<BiEmployeeMemberInfoEntity>() {
					protected Optional<Object> property(String name, String value) throws Exception {
						if ("payAmnt".equals(name)) {
							return Optional.of((Object) new BigDecimal(value).setScale(2, RoundingMode.HALF_UP));
						}
						return Optional.absent();
					}
				}), null, new TmBatchUpdateAction<BiEmployeeMemberInfoEntity>("BI_TM.SAVE_EMPLOYEE_MEMBER_INFO",batchUpdateService,timeMachineDao,cacheUtils,BiEmployeeMemberInfoEntity.class)), false);

	}
	
    /**
     * 40
     */
    @Override
    public void downloadStoreYbSaleDay(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStaffCateYbDay.class, "|@|\n",
                new DefaultLineMapper<BIStaffCateYbDay>(BIStaffCateYbDay.class,
                        new String[] { "saleVolume", "saleAmount", "ybSaleAmount","cateCode","storeCode", "storeName",
                                "disCode", "disName",  "staffId", "staffName", "saleDate",
                                "updateTime" },
                        "|$|", new SalePropertySetter<BIStaffCateYbDay>()),
                new BIStaffDataCleanService<BIStaffCateYbDay>(),
                new BatchUpdateAction<BIStaffCateYbDay>("BI_STORE_YB.REPLACE_SALE_DAY")), false);
    }
    
    /**
     * 41
     */
    @Override
    public void downloadStoreYbSaleMonth(String remoteDirectory, String date, String fileName) throws IOException {
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.downloadBIFile(remoteDirectory, fileName, localDate, new SimpleContextWithDefinition(
                BIStaffCateYbMonth.class, "|@|\n",
                new DefaultLineMapper<BIStaffCateYbMonth>(BIStaffCateYbMonth.class,
                        new String[] { "saleVolume", "saleAmount", "ybSaleAmount","cateCode","storeCode", "storeName",
                                "disCode", "disName",  "staffId", "staffName", "saleMonth",
                                "updateTime" },
                        "|$|", new SalePropertySetter<BIStaffCateYbMonth>()),
                new BIStaffDataCleanService<BIStaffCateYbMonth>(),
                new BatchUpdateAction<BIStaffCateYbMonth>("BI_STORE_YB.REPLACE_SALE_MONTH")), false);
    }

	
	/**
     * 上传已销未提所有订单号
     * 功能描述: <br>
     * 提供大数据比对是否有遗漏数据
     * 〈功能详细描述〉
     *
     * @param remoteDirectory
     * @param date
     * @param fileName
     * @throws SQLException
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @Override
    public void uploadSaleNoPickOrder(String remoteDirectory, final String date, String fileName) throws SQLException {
        final String lineSeparator = "|@|\n";
        final LocalDate localDate = new TodaySupplier(date).get();
        ftpSynService.uploadBIFile(remoteDirectory, fileName, localDate, lineSeparator,
                new SQLIterator(dataSource, selectSqls.get("uploadSaleNoPickOrder")) {
                }, new Function<Map<String, Object>, String>() {
                    @Override
                    public String apply(Map<String, Object> row) {
                        return Joiner.on("|$|").join(
                                Iterables.transform(row.entrySet(), new Function<Map.Entry<String, Object>, String>() {
                            @Override
                            public String apply(Entry<String, Object> input) {
                                // 默认直接处理成字符串
                                Object val = input.getValue();
                                if (null == val) {
                                    return "<NULL>";
                                }
                                return val.toString();
                            }
                        }));

                    }

                }, -1);
    }
    
}
